package interfaces.hud.pilot.equipment;

import java.util.ArrayList;
import java.util.List;

import logic.common.player.Player;
import logic.items.ItemProperties;
import logic.items.ItemType;
import logic.ships.hunter.Hunter;
import interfaces.hud.BasicHUD;
import interfaces.superWidgets.StaticContent;

public class ItemContent extends StaticContent {
	
	private Player player;
	private List<ItemButton> itemButtons;
	private int buttonWidth;
	private BasicHUD hud;
	
	public ItemContent(int width, int height, int x, int y, Player player, BasicHUD hud) {
		super(width, height, x, y);
		this.player = player;
		this.hud = hud;
		
		itemButtons = new ArrayList<ItemButton>();
		buttonWidth = width / 3;
		
		for(ItemProperties props : player.getTeam().getItemPropList()) {
			if(props.isButton()) addItemButton(props.getType(), props.getIconPath());
		}
		
		layout();
	}
	
	private void addItemButton(ItemType itemType, String imagePath) {
		Hunter h = player.getHunter();
		int x = buttonWidth * itemButtons.size();
		ItemButton button = new ItemButton(buttonWidth, height, x, 0, imagePath, h, itemType, hud);
		itemButtons.add(button);
		addWidget(button);
	}
}